<template>
    <div class="big-box">
        <div class="header">
            <img src="../../../../../assets/bigScreen/header4.png" alt="" />
            <div class="backBox" @click="goBack"></div>
        </div>
        <div class="backToBox">
            <div class="backTo" @click="gotoHome">
                <div>返回总窗口</div>
            </div>
            <div class="backTo" @click="backToOne">
                <div>返回上一页</div>
            </div>
        </div>
        <div class="centerBox">
            <div class="sreenTitle">投资机构</div>
            <div class="center">

                <!-- 筛选区 -->
                <div class="filter-box">
                    <div class="filter-title-box">
                        <div class="filter-title">筛选条件</div>
                        <div class="filter-input-box">
                            <!-- <div class="filter-input">
            <input type="text" placeholder="请输入关键词" v-model:value="field.name"/>
          </div>
          <div class="filter-btn" @click="pages.number=1,pages.size=5,getData">搜索</div> -->
                            <div class="searchBox">
                                <a-input-search v-model:value="field.name" placeholder="搜索信息" enter-button="查询" size="large" @search="getData"
                                    @pressEnter="getData" />
                                <!-- <a-input-search v-model:value="field.name" placeholder="搜索信息" enter-button="查询" size="large" @search="pages.number=1,pages.size=5,getData" /> -->
                            </div>
                        </div>
                    </div>
                    <div class="filter-container">
                        <div class="filter-type" v-for="(item, index) in typeList" :style="{ height: item.showMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">{{ item.title }}</div>
                            <div :class="['filter-item', typeIds[index] == null ? 'active' : '']" @click="setType(index, null)">
                                全部
                            </div>
                            <div v-for="sItem in item.list" :class="['filter-item', typeIds[index] == sItem.id ? 'active' : '']" :key="sItem.id"
                                @click="setType(index, sItem)">
                                {{ sItem.name }}
                            </div>
                            <!-- <div class="filter-more-btn" @click="item.showMore = !item.showMore">
            <span>更多分类</span>
            <img
              :style="{ transform: item.showMore ? 'scaleY(-1)' : 'scaleY(1)' }"
              src="../../../assets/down.png"
              alt=""
            />
          </div> -->
                        </div>
                        <div class="filter-type" :style="{ height: arearShowMore ? 'initial' : '55px' }">
                            <div class="filter-type-title">所在地区</div>
                            <div style="width: 110rem;">
                                <div :class="areaIndex == index ? 'filter-item active' : 'filter-item'" v-for="(item, index) in areadata[0].children"
                                    @click="areaIndex = index; pages.number=1;getOrg()" :key="index">
                                    <span v-if="item.name=='市直属'">{{areadata[0].name}}</span>
                                    <span v-else>{{item.name}}</span>
                                </div>
                                <div :class="areaIndex == -1 ? 'filter-item active' : 'filter-item'" @click="areaIndex = -1; pages.number=1;getOrg()">
                                    <span>其他</span>
                                </div>
                                <div class="filter-more-btn" @click="arearShowMore = !arearShowMore">
                                    <span>更多分类</span>
                                    <img :style="{ transform: arearShowMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png" alt="" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="broker-container">
                    <div class="broker-item" v-for="(item,index) in indexList" @click="gotoPath('/bigScreen/capitalBrokerDetail',{id: item.id})">
                        <div class="broker-img">
                            <img :src="item.image?(item.image.includes('http')?item.image:baseUrl + item.image):''" alt="" />
                        </div>
                        <div class="broker-name one-line">{{item.name}}</div>
                        <div class="broker-text two-lines">
                            <div class="broker-text-item" v-if="item.phone">
                                <img src="../../../../../assets/broker-phone.png" alt="" />
                                <span>{{item.phone}}</span>
                            </div>
                            <div class="broker-text-item">
                                <img src="../../../../../assets/broker-map.png" alt="" style="" />
                                <span class="one-line">{{item.address}}</span>
                            </div>
                        </div>
                        <div class="broker-btn">{{item.area}} | {{item.stage}}</div>
                    </div>
                </div>
                <no-data v-if="!indexList.length" />
                <div class="pagination-box">
                    <a-pagination :showSizeChanger='false' v-model:current="pages.number" v-model:pageSize="pages.size" :total="pages.total"
                        @change="onShowSizeChange" />
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import noData from "../../../no-data.vue"
import { getInvestmentInstitution } from "../../../../../api/capital"
import { ref, reactive, onBeforeMount } from "vue"
import { useRouter } from "vue-router"
import { getarea } from '../../../../../api/home'
import {baseUrl} from '../../../../../../config';
const pages = reactive({
    number: 1, //第几页
	size: 10, //每页中显示数据的条数
	total: 0
})
const field = reactive({
    type: '',
    // fieldStr: '',
    name:'',
})
const router = useRouter()
const gotoPath = (path, data) => {
    console.log('101',data);
    router.push({ path: path, query: data })
}
// function setType(index, item) {
//     console.log(index);
//     console.log(item.name);
//     pages.number = 1
// 	pages.size = 5
// 	field.name = item.name
// 	typeIds.value[index] = item ? item.id : null
//     getData()
// }
const onShowSizeChange = (current, pageSize) => {
		pages.number = current
		pages.size = pageSize
		getData()
		console.log(current, pageSize);
	};
function setType(index, item) {
    console.log(index);
    // console.log(item.name);
    pages.number = 1
    pages.size = 10
    if (index == 0) {
		// field.stage = item.name || ''
        if (item) {
            field.stage = item.name
        }
        else {
            field.stage = ''
        }
    }
    if (index == 1) {
      if (item) {
            field.nature = item.name
        }
        else {
            field.nature = ''
        }
    }
    if (index == 2) {
    
    if (item) {
            field.area = item.name
        }
        else {
            field.area = ''
        }
    }
    typeIds.value[index] = item ? item.id : null
    getData()
}
async function getData() {
    var datas={ ...field, ...pages }
    if(areaIndex.value==-1){
        datas.orgFlag = '0'
    }
    getInvestmentInstitution(datas).then((response) => {
        console.log(response);
        if (response.code == 200) {
			indexList.value = response.data.list
			pages.total = response.data.total
            //     store.setToken(response.data.token)
            //     message.success("登录成功！")
            //     router.push("/home")
        } else {
            // handleGetCode()
        }
    })
}
async function pageChange(e) {
    pages.number=e
    getData()
}
const searchBox = () => {
	// field.name = item.name
		getData()
		// console.log(current, pageSize);
	};
const current = ref(6)
const tabIndex = ref(1)
const typeIds = ref([null, null, null, null, null, null, null, null, null])
const typeList = ref([
  {
    title: "投资阶段",
    showMore: false,
    list: [
      {
        name: "不限",
        id: 1,
      },
      {
        name: "种子期",
        id: 2,
      },
      {
        name: "初创期",
        id: 3,
      },
      {
        name: "扩张期",
        id: 4,
      },
      {
        name: "成熟期",
        id: 5,
      },
    ],
  },
  {
    title: "投资性质",
    showMore: false,
    list: [
      {
        name: "不限",
        id: 1,
      },
      {
        name: "VC",
        id: 2,
      },
      {
        name: "FOCs",
        id: 3,
      },
      {
        name: "天使投资人",
        id: 4,
      },
      {
        name: "券商直投",
        id: 5,
      },
      {
        name: "VCPE",
        id: 6,
      },
      {
        name: "战略投资者",
        id: 7,
      },
      {
        name: "PE",
        id: 8,
      },
      {
        name: "风险投资",
        id: 9,
      },
    ],
  },
  // {
  //   title: "所在地区",
  //   showMore: false,
  //   list: [
  //     {
  //       name: "呼和浩特市",
  //       id: 1,
  //     },
  //     {
  //       name: "赤峰市",
  //       id: 2,
  //     },
  //     {
  //       name: "通辽市",
  //       id: 3,
  //     },
  //     {
  //       name: "包头市",
  //       id: 4,
  //     },
  //     {
  //       name: "鄂尔多斯市",
  //       id: 5,
  //     },
  //     {
  //       name: "乌兰察布市",
  //       id: 6,
  //     },
  //     {
  //       name: "二连浩特市",
  //       id: 7,
  //     },
  //   ],
  // },
])
const arearShowMore = ref(false)
const areaIndex = ref(0)
const indexList = ref({})

const areadata = ref([{children:[]}])
function getArear(){
    getarea({}).then((res) => {
        if (res.code == 200) {
            areadata.value = res.data
            if (localStorage.getItem('orgInfo')) {
                 areaIndex.value = JSON.parse(localStorage.getItem('orgInfo')).areaIndex==-1?0:JSON.parse(localStorage.getItem('orgInfo')).areaIndex
            }
        }
    })
}
const headerKey = ref(0)
function getOrg(){
   var orgInfo = {}
   if(areaIndex.value==-1){
       orgInfo = {}
   }else if(areaIndex.value==0){
       orgInfo = { orgId: areadata.value[0].id, areaIndex: areaIndex.value, areaName: '' }
   }else{
       orgInfo = { orgId: areadata.value[0].children[areaIndex.value].id, areaIndex: areaIndex.value, areaName: '' }
   }
    localStorage.setItem('orgInfo', JSON.stringify(orgInfo))
    getData()
    headerKey.value++
}
// const getList = () => {
// 		getInvestmentInstitution({
// 			// type: 0,
// 			size: 10,
// 			number: 1,
// 			// category: dataMap.category,
// 			// level: dataMap.level,
// 			name:dataMap.name
// 		}).then((res) => {
// 			dataMap.listData = res.data.list
// 			dataMap.total = res.data.total
// 			console.log(dataMap.listData)

// 		})
// 	}

const gotoHome = (act) => {
    router.push({
        path: '/bigScreenIndex',
    })
}
const backToOne = (act) => {
    router.go(-1)
}

const goBack = () => {
    router.push('/chart')
}

onBeforeMount(() => {
    getData()
    getArear()
})
</script>

<style scoped lang="scss">
@font-face {
    font-family: "ffa";
    src: url(../../../assets/bigScreen/fonts/DS-DIGIB.TTF);
}
ul,
li {
    list-style: none;
}
.big-box {
    background-color: #071c3b;
    height: 100vh;
}
.header {
    position: relative;
    text-align: center;
    position: relative;
    height: 19.1rem;

    .backBox {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 70rem;
        height: 10rem;
        cursor: pointer;
    }

    > img {
        width: 100%;
        max-height: 100%;
        margin-top: -1.1rem;
        image-rendering: -moz-crisp-edges; /* Firefox */
        image-rendering: -o-crisp-edges; /* Opera */
        image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
    }
}
.centerBox {
    width: 96%;
    margin: 0 auto;
    position: absolute;
    top: 14rem;
    left: 2%;
    .sreenTitle {
        background-image: url("../../../../../assets/bigScreen/sreenTitle.png");
        background-size: 100% 100%;
        height: 3.8rem;
        padding-left: 35px;
        font-weight: 600;
        color: #fff;
        display: flex;
        align-items: center;
    }
    .center {
        margin-top: 1rem;
        height: calc(100vh - 20rem);
        border: 1px solid;
        border-image: linear-gradient(
                130deg,
                #2385df 0%,
                rgba(35, 133, 223, 0.65) 92%
            )
            1;
        overflow-y: scroll;
        padding: 20px;

        .filter-box {
            width: 136rem;
            margin: 0 auto;
            margin-bottom: 20px;
            padding: 20px 40px;
            // background-color: #ffffff;
        }
        .filter-title-box {
            width: 100%;
            height: 60px;
            border-bottom: 1px solid #4494ff46;
        }
        .filter-title {
            line-height: 40px;
            float: left;
            font-size: 18px;
            font-weight: bold;
            color: #037aff;
        }
        .filter-input-box {
            width: 500px;
            height: 40px;
            float: right;
            .searchBox{
                ::v-deep input{
                    background: transparent;
                    color: #fff;
            border: 1px solid #4494ff46;
                }
            }
        }
        .filter-input {
            width: 380px;
            height: 40px;
            padding: 4px 20px;
            float: left;
            border-top: 1px solid #4494ff46;
            border-left: 1px solid #4494ff46;
            border-bottom: 1px solid #4494ff46;
        }
        .filter-input input {
            width: 340px;
            height: 30px;
            border: none;
            outline: none;
            background-color: transparent;
        }
        .filter-btn {
            width: 120px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            background: #037aff;
            border-top-right-radius: 4px;
            border-bottom-right-radius: 4px;
            float: left;
            font-size: 15px;
            color: #ffffff;
            cursor: pointer;
        }
        .filter-container {
            width: 100%;
            padding-top: 20px;
        }
        .filter-type {
            height: 55px;
            position: relative;
            padding-right: 90px;
            overflow: hidden;
            display: flex;
            flex-wrap: wrap;
        }
        .filter-more-btn {
            position: absolute;
            right: 0;
            top: 0;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .filter-more-btn span {
            font-size: 16px;
            color: #037aff;
        }
        .filter-more-btn img {
            width: 10px;
            height: 5px;
            margin-left: 8px;
            margin-top: 8px;
        }
        .filter-type.last .filter-item {
            margin-bottom: 0;
        }
        .filter-type-title {
            display: inline-block;
            width: 11rem;
            margin-right: 40px;
            font-size: 17px;
            font-weight: bold;
            color: #fff;
        }
        .filter-item {
            display: inline-block;
            margin-bottom: 30px;
            padding: 0 15px;
            height: 25px;
            line-height: 25px;
            border-radius: 4px;
            font-size: 16px;
            color: #fff;
            cursor: pointer;
        }
        .filter-item.active {
            background-color: #037aff;
            color: #e5f1fe;
        }
        .broker-container {
            width: 136rem;
            height: max-content;
            margin: 3rem auto;
            display: flex;
            flex-wrap: wrap;
            .broker-item {
                width: 25.6rem;
                height: 36.4rem;
                margin-right: 2rem;
                margin-bottom: 2rem;
                background-color: #082853;
                padding: 2rem;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                border: 1px solid #037dff;
                cursor: pointer;

                // box-shadow: 0px 4px 20px 0px rgba(231, 237, 247, 0.7);
                &:nth-child(5n + 5) {
                    margin-right: 0;
                }
                .broker-img {
                    width: 14rem;
                    height: 14rem;
                    margin-bottom: 1.5rem;
                    img {
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                        object-fit: cover;
                    }
                }
                .broker-name {
                    font-size: 2rem;
                    font-weight: bold;
                    color: #fff;
                    width: 100%;
                }
                .broker-text {
                    margin-top: 1.5rem;
                    margin-bottom: 2rem;
                    font-size: 1.5rem;
                    line-height: 2.5rem;
                    height: 5rem;
                    color: #fff;
                    width: 100%;
                    .broker-text-item {
                        display: flex;
                        align-items: center;
                        img {
                            width: 1.5rem;
                            height: auto;
                            margin-right: 0.5rem;
                        }
                    }
                }
                .broker-btn {
                    width: 100%;
                    // line-height: 3.4rem;
                    // border-radius: 4px;
                    // background: #037dff;
                    text-align: center;
                    // background-color: #037aff;
                    font-size: 1.4rem;
                    font-weight: bold;
                    color: #b2b2b2;
                    cursor: pointer;
                }
                &:last-child {
                    margin-right: 0;
                }
            }
        }
        .pagination-box {
            width: 100%;
            height: 10rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
    ::-webkit-scrollbar {
        width: 5px;
        height: 10px;
    }

    /* 滚动条轨道 */
    ::-webkit-scrollbar-track {
        background-color: #234470;
    }

    /* 滚动条滑块 */
    ::-webkit-scrollbar-thumb {
        background-color: #061c57;
    }

    /* 鼠标悬停在滚动条上的滑块 */
    ::-webkit-scrollbar-thumb:hover {
        background-color: #555;
    }
}
.backToBox {
    position: absolute;
    top: 8rem;
    right: 2%;
    display: flex;
    .backTo {
        background-image: url("../../../../../assets/bigScreen/backTo.png");
        color: #2dccff;
        background-size: 100% 100%;
        width: fit-content;
        padding: 2px 40px 10px 10px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 10px;
        div {
            padding-top: 5px;
        }
    }
}::v-deep {
    .ant-btn-primary {
        border-color: #037aff;
        background: #037aff;
    }

    .ant-input {
        background: rgba(68, 148, 255, 0.12);
        border: none;
        color: #ffffff;
    }

    .ant-pagination-item {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
    }

    .ant-pagination-item a {
        color: #ffffff;
    }

    .ant-pagination-prev .ant-pagination-item-link,
    .ant-pagination-next .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-disabled .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-item-active {
        background: #004dfd;
        border-radius: 2px;
        border: none;
    }

    .ant-pagination-jump-prev
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis,
    .ant-pagination-jump-next
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis {
        color: #ffffff;
    }
    .ant-select-selector {
        background-color: transparent !important;
        background: rgba(8, 26, 48, 0.8) !important;
        border: 1px solid #0b2f5f !important;
        color: #ffffff !important;
    }
}
</style>
